﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width" />
    <title>图片预览</title>
    <style>
        html, body {
            overflow: hidden;
        }

        * {
            margin: 0;
            padding: 0;
        }

        #dowebok {
            width: 60%;
            margin: 30px auto 0;
            font-size: 0;
        }

            #dowebok li {
                display: inline-block;
                width: 31%;
                margin-left: 1%;
                height: 200px;
                border: 4px solid #ddd;
                cursor: pointer;
            }

                #dowebok li img {
                    width: 100%;
                    height: 100%;
                }
    </style>
</head>
<body>

    <ul id="dowebok"></ul>

    <script src="~/Content/jquery/jquery.min.js"></script>
    <script src="~/Content/static/Content/Lib/viewer/js/viewer.min.js"></script>
    <script>
        function request(d) { for (var c = location.search.slice(1).split("&"), a = 0; a < c.length; a++) { var b = c[a].split("="); if (b[0] == d) if ("undefined" == unescape(b[1])) break; else return unescape(b[1]) } return "" };
        var folderId = request("folderId");
        if (folderId) {
            $.ajax({
                type: 'GET',
                url: "/LR_SystemModule/Annexes/GetAnnexesFileList?folderId=" + folderId,
                success: function (data) {
                    var data = JSON.parse(data);
                    var html = '';
                    if (data.code == 200) {
                        var list = data.data;
                        if (list.length > 0) {
                            for (var i = 0; i < list.length; i++) {
                                var isTrue = IsPicture(list[i].F_FileName);
                                if (isTrue) {
                                    html += '<li><img data-original="/LR_SystemModule/Annexes/PreviewFile?fileId=' + list[i].F_Id + '" src="/LR_SystemModule/Annexes/PreviewFile?fileId=' + list[i].F_Id + '" alt=""></li>';
                                }
                            }
                            $("#dowebok").html(html);
                            var viewer = new Viewer(document.getElementById('dowebok'), {
                                url: 'data-original'
                            });
                        }
                    }
                }
            });
        } else {
            console.error("folderId没传")
        }

        function IsPicture(str) {
            var strFilter = ".jpeg|.gif|.jpg|.png|.bmp|.pic|.svg|"
            if (str.indexOf(".") > -1) {
                var p = str.lastIndexOf(".");
                var strPostfix = str.substring(p, str.length) + '|';
                strPostfix = strPostfix.toLowerCase();
                if (strFilter.indexOf(strPostfix) > -1) {
                    return true;
                }
            }
            return false;
        }

    </script>
</body>
</html>
